<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>订单号：</label>
                                <input type="text" name="orderNo"/>
                            </li>
                            <li class="select-time">
                                <label>订单日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginOrderDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endOrderDate]"/>
                            </li>
                            <li>
                                <label>订单状态：</label>
                                <select name="sattus"  th:with="type=${@dict.getType('order_status')}">
                                    <option value="">全部</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="goods:order:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('goods:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('goods:order:remove')}]];
        var prefix = ctx + "goods/order";
        var datas = [[${@dict.getType('order_status')}]];
        var d_pay_channel = [[${@dict.getType('pay_channel')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                modalName: "订单",
                detailView: true,
                onExpandRow : function(index, row, $detail) {
                    initChildTable(index, row, $detail);
                },
                columns: [{
                    checkbox: true
                },
                {
                    field: 'orderNo',
                    title: '订单号'
                },
                {
                    field: 'orderMoney',
                    title: '订单总金额'
                },
                {
                    field: 'orderTime',
                    title: '订单时间'
                },
                {
                    field: 'status',
                    title: '订单状态',
                    formatter:function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'payChannelId',
                    title: '支付渠道',
                    formatter:function (value, row, index) {
                        return $.table.selectDictLabel(d_pay_channel, value);
                    }
                },
                {
                    field: 'createBy',
                    title: '操作员'
                },
                {
                    field: 'memo',
                    title: '备注'
                }
                ]
            };
            $.table.init(options);
        });

        initChildTable = function(index, row, $detail) {
            var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
            var prefixDownload=ctx + "common/download/resource?resource=";

            $(childTable).bootstrapTable({
                url: ctx + "goods/orderHead/list",
                method: 'post',
                sidePagination: "server",
                contentType: "application/x-www-form-urlencoded",
                queryParams : {
                    orderNo: row.orderNo
                },
                columns: [
                {
                    field: 'imgPath',
                    title: '图片',
                    formatter: function(value, row, index) {
                        //console.log(row.imgPath)
                        if(row.imgPath==''||row.imgPath==null){
                            return '';
                        }else{
                            return $.table.imageView(prefixDownload+row.imgPath);
                        }
                    }
                },
                {
                    field : 'styleNumber',
                    title : '款号'
                },
                {
                    field : 'goodsName',
                    title : '货名'
                },
                {
                    field : 'preferentialPrice',
                    title : '优惠价'
                },
                {
                    field : 'quantity',
                    title : '数量'
                },
                {
                    field : 'money',
                    title : '金额'
                }
                ]
            });
        };
    </script>
</body>
</html>